package com.kd.enums.employee;

/**
 * 员工状态枚举
 */
public enum EmployeeStatus {
    RESIGNED(0, "离职"),
    ON_LEAVE(1, "休假"),
    ON_JOB(2, "在职");

    private final Integer code;
    private final String desc;

    EmployeeStatus(Integer code, String desc) {
        this.code  = code;
        this.desc  = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据code获取枚举
     */
    public static EmployeeStatus getByCode(Integer code) {
        for (EmployeeStatus status : values()) {
            if (status.code.equals(code))  {
                return status;
            }
        }
        throw new IllegalArgumentException("无效状态码: " + code);
    }
}